package com.example.designer.observer.impl;

import com.example.designer.observer.inter.Displayelement;
import com.example.designer.observer.inter.Observer;
import com.example.designer.observer.inter.Subject;

public class CurrentConditionDisplay implements Observer, Displayelement {

    private float temperature;//温度
    private float humidity;//湿度
    private float pressure;//压力

    //注册自己到主题
    public CurrentConditionDisplay(Subject weatherData) {
        weatherData.registerObserver(this);
    }


    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        display();
    }


    @Override
    public void display() {
        System.out.println("CurrentConditionDisplay{" +
                "temperature : " + temperature +
                ", humidit : " + humidity +
                ", pressure : " + pressure +
                '}');
    }
}
